<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>在线考试系统 - 登录</title>
  <style>

    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      background: url('/images/login_bg.png') no-repeat center center fixed;
      background-size: cover;
      display: flex;
      justify-content: center;
      align-items: flex-start; /* 修改为顶部对齐 */
      min-height: 100vh;
      margin: 0;
      position: relative;
      padding-top: 60px; /* 添加顶部内边距 */
    }

    /* 添加半透明遮罩层 */
    body::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(255, 255, 255, 0.85);
      z-index: -1;
    }

    .login-container {
      width: 350px;
      padding: 40px 30px;
      background: white;
      border-radius: 12px;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
      transition: all 0.3s ease;
      border: 1px solid #eaeaea;
      margin-top: 40px; /* 减少顶部外边距 */
    }

    .login-container:hover {
      box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
      transform: translateY(-2px); /* 减少悬停上移距离 */
    }

    .login-container h2 {
      text-align: center;
      color: #2c3e50;
      margin-bottom: 30px;
      font-weight: 600;
      font-size: 28px;
      letter-spacing: 1px;
    }

    .form-group {
      margin-bottom: 25px;
      position: relative;
    }

    label {
      display: block;
      margin-bottom: 8px;
      color: #555;
      font-weight: 500;
      font-size: 14px;
    }

    input[type="text"],
    input[type="password"] {
      width: 100%;
      padding: 12px 15px;
      border: 1px solid #ddd;
      border-radius: 8px;
      font-size: 16px;
      transition: all 0.3s;
      box-sizing: border-box;
      background: #f9f9f9;
    }

    input[type="text"]:focus,
    input[type="password"]:focus {
      border-color: #3498db;
      box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
      outline: none;
      background: white;
    }

    button {
      width: 100%;
      padding: 14px;
      background: linear-gradient(to right, #3498db, #2c3e50);
      color: white;
      border: none;
      border-radius: 8px;
      cursor: pointer;
      font-size: 16px;
      font-weight: 600;
      letter-spacing: 1px;
      transition: all 0.3s ease;
      margin-top: 10px;
      box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
    }

    button:hover {
      transform: translateY(-2px);
      box-shadow: 0 6px 15px rgba(52, 152, 219, 0.4);
    }

    button:active {
      transform: translateY(0);
    }

    .error {
      color: #e74c3c;
      font-size: 14px;
      text-align: center;
      margin: 15px 0;
      padding: 10px;
      background: rgba(231, 76, 60, 0.1);
      border-radius: 6px;
      border-left: 4px solid #e74c3c;
    }

    .logo {
      text-align: center;
      margin-bottom: 30px;
      color: #2c3e50;
      font-size: 24px;
      font-weight: bold;
      letter-spacing: 2px;
    }

    .mt-3 {
      margin-top: 18px;
    }

    .text-center {
      text-align: center;
    }

  </style>
</head>
<body>
<div class="login-container">
  <div class="logo">源麟考试系统</div>
  <h2>用户登录</h2>

  <!-- 错误消息提示 -->
  <div th:if="${error}" class="alert alert-danger" role="alert">
    <span th:text="${error}"></span>
  </div>

  <!-- 注册成功消息提示 -->
  <div th:if="${success}" class="alert alert-success" role="alert">
    <span th:text="${success}"></span>
  </div>

  <form th:action="@{/login}" method="post">
    <div class="form-group">
      <label>用户ID</label>
      <input type="text" name="userId" required placeholder="请输入用户ID">
    </div>
    <div class="form-group">
      <label>密码</label>
      <input type="password" name="password" required placeholder="请输入密码">
    </div>
    <div th:if="${error}" class="error" th:text="${error}"></div>
    <button type="submit">登&nbsp;&nbsp;&nbsp;录</button>
    <!-- 在登录表单下方添加 -->
    <div class="mt-3 text-center">
      <p>还没有账号? <a th:href="@{/register}">立即注册</a></p>
    </div>
  </form>
</div>
</body>
</html>